	var oTel=document.getElementById('tel');
	var otxt1=document.getElementById('txt1');
	var otxt2=document.getElementById('txt2');
	var oPwd=document.getElementById('pwd');
	var oF = document.querySelector("form");
	
	
		var regnum=/^\d{11}$/;
		var flagnum=false;
	oTel.onblur=function(){
		if(regnum.test(this.value)){
			flagnum = true;
			otxt1.innerHTML = "输入合法";
		}else{
			flagnum = false;
			otxt1.innerHTML = "输入不合法";
		}
	}
		var regpwd=/^(?!.*\s)(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*[\W_]).{8,16}$/;
		var flagpwd = false;
		oPwd.onblur = function(){
			if(regpwd.test(this.value)){
				flagpwd = true;
				otxt2.innerHTML = "输入合法";
			}else{
				flagpwd= false;
				otxt2.innerHTML = "输入不合法";
			}
		}
		var oBtn=document.getElementById('code');
		var otxt3=document.getElementById('txt3');
		
			oBtn.onclick=function(){
				console.log(code(4));
				otxt3.innerHTML=code(4);
			}
			function code(num){
				var str="0123456789qwertyuiopasdfghjklzxcvbnm";
				var newstr="";
					for(var i=0;i<num;i++){
						var n=parseInt(Math.random()*str.length);
						newstr +=str.charAt(n)
					}
					return newstr;
					console.log(newstr);
					console.log(code(4));
			}
		var oscode=document.getElementById('scode');
		var otxt4=document.getElementById('txt4');
		oscode.onblur=function(){
			if(oscode.value==otxt3.innerHTML){
				otxt4.innerHTML='输入正确！'
			}else{
				otxt4.innerHTML='请重新输入'
			}
			
			if(this.value==''){
				otxt4.innerHTML = "输入不合法";
			}
		}
		
		
		
		var flagyCode = false;
			oF.onsubmit = function(){
				if(flagnum && flagpwd){
					return true;
				}else{
					return false;
				}
			}
			
			var opwd=document.getElementById('pwd');
			var oSub=document.getElementById('sub');
		
			oSub.onclick=function(){
			console.log(111)
			var xhr = new XMLHttpRequest();
				xhr.open('post', '../php/zhuce.php');
				xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
				xhr.send('&username=' + oTel.value + '&password=' + oPwd.value);
				xhr.onreadystatechange = function() {
					if (xhr.readyState == 4 && xhr.status == 200) {
						if (xhr.responseText == '0') {
							alert('注册失败');
						} else {
							location.href = '../html/denglu.html';
						}
					}
				}
			}
		